package phenix.com.phenixdemo;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;

import de.greenrobot.event.EventBus;
import phenix.com.phenixdemo.event.EventAsync;
import phenix.com.phenixdemo.event.EventBackground;
import phenix.com.phenixdemo.event.EventMain;
import phenix.com.phenixdemo.event.EventPost;


/**
 * AndroidAnnotations 注解框架测试
 */
@EActivity(R.layout.activity_activity_master)
public class ActivityMaster extends AppCompatActivity {

//    @ViewById   //注解方式
//    FloatingActionButton fab;

    @AfterViews
    public void init(){
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_activity_master);
        Log.i(">>>>>>>Event<<<<<<<<","onCreate+++++++++++++ActivityMaster");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().post(new EventPost());
        EventBus.getDefault().post(new EventMain());
        EventBus.getDefault().post(new EventBackground());
        EventBus.getDefault().post(new EventAsync());
    }
}
